package com.cloudeasy.provider.service.impl;

import com.cloudeasy.core.support.BaseService;
import com.cloudeasy.provider.mapper.UacGroupUserMapper;
import com.cloudeasy.provider.model.domain.UacGroup;
import com.cloudeasy.provider.model.domain.UacGroupUser;
import com.cloudeasy.provider.service.UacGroupUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Create By 郭金宝 on 2019/1/14.<br>
 */
@Service
public class UacGroupUserServiceImpl extends BaseService<UacGroupUser> implements UacGroupUserService {
    @Resource
    private UacGroupUserMapper uacGroupUserMapper;

    @Override
    public UacGroupUser queryByUserId(Long userId) {
        return uacGroupUserMapper.getByUserId(userId);
    }

    @Override
    public int updateByUserId(UacGroupUser uacGroupUser) {
        return uacGroupUserMapper.updateByUserId(uacGroupUser);
    }

    @Override
    public List<UacGroup> getGroupListByUserId(Long userId) {
        return uacGroupUserMapper.selectGroupListByUserId(userId);
    }

    @Override
    public void saveUserGroup(Long userId, Long groupId) {
        UacGroupUser groupUser = new UacGroupUser();
        groupUser.setUserId(userId);
        groupUser.setGroupId(groupId);
        uacGroupUserMapper.insertSelective(groupUser);
    }
}